﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Wys.ClosePopup
{
    public class EITABLEClosePopup:IClosePopup 
    {
        public bool CloseWindow(IntPtr hWnd,ref String strMsg)
        {
            IntPtr btnHandle = Win32.FindWindowEx(hWnd, 0, "WindowsForms10.BUTTON.app.0.b7ab7b", "OK");
            if (btnHandle == IntPtr.Zero)
            {
                btnHandle = Win32.FindWindowEx(hWnd, 0, "WindowsForms10.BUTTON.app.0.33c0d9d", "OK");
                if (btnHandle == IntPtr.Zero)
                {
                    btnHandle = Win32.FindWindowEx(hWnd, 0, null, "OK");
                }
            }

            if (btnHandle == IntPtr.Zero)
            {
                long lRet = Win32.SendMessage(hWnd, 0x10, 0, 0);
            }
            else
            {
                if (Win32.IsWindowEnabled(btnHandle) == false)
                {
                    Win32.EnableWindow(btnHandle, true);
                }
                Win32.SendMessage(btnHandle, Win32.BM_CLICK, 0, 0);
            }
            return true;
        }
    }
}
